#!/bin/bash

add="/root/vitepress/SB"
# 创建目录
mkdir -p $add

# 生成 docker-compose 文件
cat << EOF > $add/docker-compose-nastool-php-nginx.yaml
version: '3'  
services:  
  nginx:
    image: nginx:latest  
    ports:  
      - "8999:80"  
    volumes:  
      - $add:/usr/share/nginx/html  
      - $add/default.conf:/etc/nginx/nginx.conf  
    restart: always
    networks:  
      - mynetwork
    container_name: 01-nginx-SB2
  phpfpm:  
    image: php:8.3.6-fpm  
    volumes:  
      - $add:/www  
    environment:
      - TZ=Asia/Shanghai 
    restart: always
    networks:  
      - mynetwork  
    container_name: myphp-fpm
networks:  
  mynetwork:
EOF

# 下载 nginx 配置文件
wget -O $add/default.conf --no-check-certificate https://gitee.com/juway111/centos-server-recovery/raw/master/%E6%A0%B8%E5%BF%83PHP%E6%9C%8D%E5%8A%A1%E5%99%A8/default.conf

chmod -R 777 $add
# 运行 docker-compose 命令
docker-compose -p php-nginx -f $add/docker-compose-nastool-php-nginx.yaml up -d